import { currentApp, currentMicro, getSeed } from "@/views/seed-dev";
import ActionEditor from "./src/ActionEditor.vue";
import ActionCreator from "./src/ActionCreator.vue";
import { ActionConfiguration } from "@/views/dev-types";
export { ActionEditor, ActionCreator }

export function save(name: string, data: ActionConfiguration, seedName?: string) {
  if(seedName) {
    const seed = getSeed(seedName)
    seed.actions = seed.actions || {}
    seed.actions[name] = data
  } else {
    const microName = currentMicro.value
    if(microName) {
      const micro = currentApp.value.micros[microName]
      micro.actions = micro.actions || {}
      micro.actions[name] = data
    } else {
      const app = currentApp.value
      app.actions = app.actions || {}
      app.actions[name] = data
    }
  }
}